// import {getUserFromJwt} from '~/utils/serveCommon'
import {updateTag} from '~/server/database/repositories/tag'
export default defineEventHandler(async(context)=>{
  try{
    const tag = await readBody(context) || {} // 读取参数
    const { id,name,sign,kind } = tag
    if(!id || !name || !sign || !kind){
      return sendError(context,createError({
        statusCode: 400,
        statusMessage: '参数错误!',
      }))
    }
    const updatedData = await updateTag(tag)
    if(updatedData){
      return { resource: tag, msg:'更新标签成功!' }
    }{
      return sendError(context, createError({
        statusCode: 400,
        statusMessage: '更新标签失败！',
      }))
    }
  }
  catch(error){
    return sendError(context, createError({
      statusCode: 500,
      statusMessage: '更新标签失败！',
    }))
  }
})